package main
import (
	"fmt"
	"net"
	"time"
	"manyuser/server/model"
)

func processOne(conn net.Conn){
	defer conn.Close()
	err:=(&Processor{conn}).Processing()
	if err!=nil{
		fmt.Println("(&Processor{conn}).Processing() wrong,",err)
	}
}

func main(){
	//初始化工作
	initPool("localhost:6379",16,0,3000*time.Second)
	model.MyUserDao=model.NewUserDao(pool)

	fmt.Println("server is listening at 8889")
	listen,err:=net.Listen("tcp","0.0.0.0:8889")
	defer listen.Close()

	if err!=nil{
		fmt.Println("server has a wrong listening and it is",err)
		return
	}
	for{
		fmt.Println("server is waitting client to hello")
		conn,err:=listen.Accept()
		if err!=nil{
			fmt.Println("listen accept wrong,",err)
		}else{
			go processOne(conn)
		}
	}
}